package controllers

import (
	"github.com/astaxie/beego"
	"lottery/service"
	"encoding/json"
	"fmt"
	"lottery/models"
)
//手动触发开奖
type LotteryController struct {
	beego.Controller
	service.Lottery
}

// @Title Create
// @Description 开奖
// @Param	body		body 	models.Bet	true		"The bet arrays"
// @Success 200 {string} models.Bet.Id
// @Failure 403 body is empty
// @router / [post]
func (ctrl *LotteryController) Post() {
	var  lottery []*models.Lottery;
	json.Unmarshal(ctrl.Ctx.Input.RequestBody, &lottery)
	// mailId int64
	status,err := ctrl.Lottery.AddItem(lottery)
	var rsp models.Rsp
	if err!=nil {
		rsp=models.Rsp{Status:status,Error:err.Error()}
	}else{
		rsp=models.Rsp{Error:"ok"}
		fmt.Println(rsp)
	}
	ctrl.Data["json"] =rsp
	ctrl.ServeJSON()
}